<?php

use think\migration\Migrator;
use think\migration\db\Column;

class DeliverDriverAccountLog extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('deliver_driver_account_log', ['comment' => '司机账户流水表'])
             ->addColumn('deliver_driver_id', 'integer', ['limit' => 11, 'default' => 0, 'after' => 'id', 'comment' => '司机ID'])
             ->addColumn('type', 'integer', ['limit' => 11, 'default' => 1, 'after' => 'deliver_driver_id', 'comment' => '类型 1:分佣 2:提现'])
             ->addColumn('amount', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0, 'after' => 'type', 'comment' => '变动金额'])
             ->addColumn('money', 'decimal', ['precision' => 10, 'scale' => 2, 'default' => 0, 'after' => 'amount', 'comment' => '余额'])
             ->addColumn('remark', 'string', ['limit' => 255, 'default' => '', 'after' => 'money', 'comment' => '备注'])
             ->addColumn('create_time', 'integer', ['limit' => 11, 'default' => 0, 'after' => 'remark', 'comment' => '创建时间'])
             ->addColumn('update_time', 'integer', ['limit' => 11, 'default' => 0, 'after' => 'create_time', 'comment' => '更新时间'])
             ->addColumn('delete_time', 'integer', ['limit' => 11, 'default' => 0, 'after' => 'update_time', 'comment' => '删除时间'])
             ->addColumn('status', 'integer', ['limit' => 11, 'default' => 0, 'after' => 'delete_time', 'comment' => '状态'])
             ->create();
    }
}
